<template tag="以下文档内容为hycli自动生成">
  <div style="height: 100%">
    <div style="margin:0.8rem;"><h5 style="display:inline">员工信息</h5><span style="margin-left: 0.5rem; color:#999"> 管理员工基本信息，所属部门，业务线等</span>
        <ddmenu :menuList="lob_idList" @valueChanged="onlob_idChange" v-model="form_aaayr.lob_id" menuType="my_business_line" ></ddmenu>
    </div>
    <hr style="margin-top:0;color:#999"/>
<div class="query">
    
    <div class="tabs">
        <el-tabs v-model="form_aaayr.status"  @tab-change="onQuery">
            <el-tab-pane v-for="item in statusTabList" :name="item.value" :key="item.value" :label="item.name" 
             ></el-tab-pane>
          </el-tabs>
    </div>
    <el-form :model="form_aaayr" inline >
        <!-- 日期控件个数： 0 -->
        <!--部门 下拉控件 -->
        <el-form-item>
            <el-select  v-model="form_aaayr.dpt_id" style="width: 100px" filterable clearable placeholder="部门">
                <el-option v-for="item in dpt_idList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!--岗位 下拉控件 -->
        <el-form-item>
            <el-select  v-model="form_aaayr.position" style="width: 100px" filterable clearable placeholder="岗位">
                <el-option v-for="item in positionList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!--邮件通知 下拉控件 -->
        <el-form-item>
            <el-select  v-model="form_aaayr.is_email_enabled" style="width: 100px" filterable clearable placeholder="邮件通知">
                <el-option v-for="item in is_email_enabledList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!--职位 下拉控件多选 -->
        <el-form-item>
            <el-select v-model="form_aaayr.title" filterable clearable multiple collapse-tags  style="width: 140px"
            collapse-tags-tooltip placeholder="职位">
                <el-option v-for="item in titleList" :key="item.value" :label="item.name" :value="item.value" />
            </el-select>
        </el-form-item>
        <!-- 控件个数：[{"index":7,"raw":"name","name":"name","cname":"Name","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["c","u","l","le","q","v","DN","#like"],"desc":{"raw":"名称","name":"名称"}}] -->
         <el-form-item>
            <el-input clearable style="width: 180px" v-model="form_aaayr.single_text_value" maxlength="32"
                placeholder="关键字" >
                <template #prepend>
                    <el-select v-model="form_aaayr.single_text_name" placeholder="查询类型" style="width:84px;">
                        <el-option
                        v-for="item in multiQueryText"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                      />
                      </el-select>
                  </template>
            </el-input>
        </el-form-item>

        <span class="ddl">
        </span>
        <el-form-item>
            <el-space wrap>
                <el-button type="primary" icon="Search" @click="onQuery(true)">查询</el-button>
            </el-space>
        </el-form-item>
        
        <div class="blist">
            <el-button-group>
                <el-button :type="$js.page.tagColor(0)"
                
                 icon="Plus"  @click="show_cmpnt_aaayv">添加员工</el-button>
                <el-button :type="$js.page.tagColor(1)"
                 :disabled="bcheck.length==0" 
                 icon="right"  @click="show_cmpnt_aaayw">修改部门</el-button>
            </el-button-group>
        </div>

        <!-- xtabs -->
        

    </el-form>
</div>
<div>
   <aaayv ref="cmpnt_aaayv" @onsaved="onQuery"></aaayv>
   <aaayt ref="cmpnt_aaayt" @onsaved="onQuery"></aaayt>
   <aaayu ref="cmpnt_aaayu" @onsaved="onQuery"></aaayu>
   <aaayw ref="cmpnt_aaayw" @onsaved="onQuery"></aaayw>
</div>
<div class="list">
    <el-table :data="dataList_aaayr"
    @selection-change="handleSelectionChange" 
    v-loading="conf.loading" stripe  style="width: 100%;height:calc(100vh - 160px)"
         empty-text="无数据">le
<el-table-column width="24px" type="expand">
    <template #default="view">
        <el-row :gutter="24">
            <el-col :span="5" class="text-right" style="min-height:26px">编号:</el-col>
            <el-col :span="7" v-text="view.row.le_staff_id" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">名称:</el-col>
            <el-col :span="7" v-text="view.row.le_name" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">部门:</el-col>
            <el-col :span="7" v-text="view.row.dpt_id_label" style="min-height:26px"
              :class="$js.page.colorful(view.row.dpt_id,'dpt_id')" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">业务线:</el-col>
            <el-col :span="7" v-text="view.row.lob_id_label" style="min-height:26px"
              :class="$js.page.colorful(view.row.lob_id,'lob_id')" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">岗位:</el-col>
            <el-col :span="7" v-text="view.row.position_label" style="min-height:26px"
              :class="$js.page.colorful(view.row.position,'position')" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">职位:</el-col>
            <el-col :span="7" v-text="view.row.title_label" style="min-height:26px"
              :class="$js.page.colorful(view.row.title,'title')" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">手机:</el-col>
            <el-col :span="7" v-text="view.row.le_mobile" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">邮箱:</el-col>
            <el-col :span="7" v-text="view.row.le_email" style="min-height:26px" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">邮件通知:</el-col>
            <el-col :span="7" v-text="view.row.is_email_enabled_label" style="min-height:26px"
              ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">状态:</el-col>
            <el-col :span="7" v-text="view.row.status_label" style="min-height:26px"
              :class="$js.page.colorful(view.row.status,'status')" ></el-col>
            <el-col :span="5" class="text-right" style="min-height:26px">创建时间:</el-col>
            <el-col :span="7" v-text="view.row.le_create_time" style="min-height:26px" ></el-col>
        </el-row>
    </template>
</el-table-column>
          <el-table-column type="selection" width="32" /> 
        	<!--staff_id text -->
        <el-table-column  show-overflow-tooltip    align="center" label="编号" >
            <template #default="scope">
                  <span>{{ scope.row.staff_id||'-' }}</span>
              </template>
        </el-table-column>
        	<!--name text -->
        <el-table-column  show-overflow-tooltip    align="center" label="名称" >
            <template #default="scope">
                  <span>{{ scope.row.name||'-' }}</span>
              </template>
        </el-table-column>
        	<!--dpt_id tree -->
        <el-table-column  :filters="dpt_idList" :filter-method="$js.page.columnfilter" column-key="dpt_id"    min-width="160"   prop="dpt_id" align="center" label="部门">
            <template #default="scope">
                <span :class="$js.page.colorful(scope.row.dpt_id,'dpt_id')" 
                    v-text="scope.row.dpt_id_label"></span>
            </template>
        </el-table-column>
        	<!--lob_id select -->
        <el-table-column  :filters="lob_idList" :filter-method="$js.page.columnfilter" column-key="lob_id"    min-width="200"   prop="lob_id" align="center" label="业务线">
            <template #default="scope">
                <span :class="$js.page.colorful(scope.row.lob_id,'lob_id')" 
                    v-text="scope.row.lob_id_label"></span>
            </template>
        </el-table-column>
        	<!--position select -->
        <el-table-column  :filters="positionList" :filter-method="$js.page.columnfilter" column-key="position"     prop="position" align="center" label="岗位">
            <template #default="scope">
                <span :class="$js.page.colorful(scope.row.position,'position')" 
                    v-text="scope.row.position_label"></span>
            </template>
        </el-table-column>
        	<!--title multiselect -->
        <el-table-column  :filters="titleList" :filter-method="$js.page.columnfilter" column-key="title"     prop="title" align="center" label="职位">
            <template #default="scope">
                <span :class="$js.page.colorful(scope.row.title,'title')" 
                    v-text="scope.row.title_label"></span>
            </template>
        </el-table-column>
        	<!--mobile text -->
        <el-table-column  show-overflow-tooltip    align="center" label="手机" >
            <template #default="scope">
                  <span>{{ scope.row.mobile||'-' }}</span>
              </template>
        </el-table-column>
        	<!--status switch -->
        <el-table-column     align="center" label="状态">
            <template #default="scope">
                <el-switch  @change="onstatusSwitchChange(scope.row,$event)"  v-model="scope.row.status_switch" />
            </template>
        </el-table-column>
        	<!--create_time date -->
        <el-table-column  show-overflow-tooltip    align="center" label="创建时间" >
            <template #default="scope">
                  <span>{{ scope.row.create_time||'-' }}</span>
              </template>
        </el-table-column>

<el-table-column fixed="right" align="center" label="操作" width="112">
    <template #default="scope">
        <div class="opts">
            <el-button   type="text" @click="show_cmpnt_aaayt(scope.row)" >详情 </el-button>
            <el-button   type="text" @click="show_cmpnt_aaayu(scope.row)" >修改 </el-button>
        </div>
    </template>
</el-table-column>
    </el-table>
    <el-pagination :currentPage="form_aaayr.pi" :page-size="form_aaayr.ps"
        style="position: absolute; right: 30px;bottom:6px;" :page-sizes="[10,15,20,30, 50, 100]" :background="false" small
        layout="total,sizes,prev, pager, next, jumper" :total="total_aaayr" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />
</div>
  </div>
</template>
<script>
// 添加员工
import aaayv from "@/views/ws/staff/staff_info.add"
// 详情
import aaayt from "@/views/ws/staff/staff_info.view"
// 修改
import aaayu from "@/views/ws/staff/staff_info.edit"
// 修改部门
import aaayw from "@/views/ws/staff/staff_info.dialog"
// 业务线
import ddmenu from "@/views/cmpnts/ddMenu.vue"



export default {
components: {
    aaayv,
    aaayt,
    aaayu,
    aaayw,
     ddmenu,
},
data() {
  return {
    shortcuts: this.$js.page.latestDays(),
    cmpnt_funcs:{},
    bcheck:[],
    conf: {
      loading: false,
      progressColor: this.$theia.env.conf.progress || []
    },
    ganttIdx: -1,
        form_aaayr: {
            pi: 1,
            ps: 15,
            disabled:false,
            single_date_range_name:"",
            single_date_range_value:[],
            single_text_name:"",
            single_text_value:"",
            name:"",
            dpt_id:"",
            lob_id:"",
            position:"",
            title:[],
            is_email_enabled:"",
            status:"",
            },
            dpt_idList:[],
            lob_idList:[],
            positionList:[],
            titleExts:[],
            titleList:[],
            is_email_enabledList:[],
            statusList:[],
            statusTabList:[],
            dataList_aaayr:[],
            multiQueryDateRange:[],
            multiQueryText:[{label:"名称",value:"name"},],
            total_aaayr:0,
            note_dataList:[],
};
  },
mounted() {
  this.loadEnums_aaayr()
  this.form_aaayr.lob_id = this.$theia.user.get("lob_id")
  this.form_aaayr.single_date_range_name = (this.multiQueryDateRange[0]||{}).value
  this.form_aaayr.single_text_name = (this.multiQueryText[0]||{}).value
  this.cmpnt_funcs["aaayv"] = this.show_cmpnt_aaayv
  this.cmpnt_funcs["aaayt"] = this.show_cmpnt_aaayt
  this.cmpnt_funcs["aaayu"] = this.show_cmpnt_aaayu
  this.cmpnt_funcs["aaayw"] = this.show_cmpnt_aaayw

  this.form_aaayr = Object.assign(this.form_aaayr,this.$route.params)
    },
 watch: {
    '$route' () {
      this.form_aaayr = Object.assign(this.form_aaayr,this.$route.params)
      this.onQuery();//我的初始化方法
    }
  },
methods: {
  ganttChange(id) {
      this.ganttIdx = id
    },

queryData_aaayr(mform = {},nform={}){
    //构建查询参数
    let queryForm = Object.assign({},this.form_aaayr)
    queryForm = Object.assign(queryForm,nform||{})
    
    //处理多个日期选择
    queryForm[this.form_aaayr.single_date_range_name] = this.form_aaayr.single_date_range_value
    queryForm[this.form_aaayr.single_text_name] = this.form_aaayr.single_text_value
   
    //处理日期范围选择
      queryForm.title = (queryForm.title||[]).join(",")

    queryForm[this.form_aaayr.single_date_range_name] = null
    queryForm.single_date_range_value = null
    queryForm.single_date_range_name = null

    queryForm.single_text_value = null
    queryForm.single_text_name = null
 
    //处理关联表staff_info staff_info staff_info
   
    //发送查询请求
    let that = this
    that.conf.loading = true
    //构建统计查询
  //数据查询
  this.$theia.http.get("/ws/staff/info/query",queryForm).then(res=>{
      if((res.items||[]).length < (queryForm.ps||10)){
        that.form_aaayr.disabled = true
      }
      that.conf.loading = false
      that.dataList_aaayr = res.items||[]
      that.total_aaayr = res.count
      that.resetItemData_aaayr(that,that.dataList_aaayr)
    });
  },

  resetItemData_aaayr(that,lst){
    lst.forEach(item => {
      item.__raw = Object.assign({}, item)
    item.dpt_id_label = that.$theia.enum.getTreeNames("department_info",item.dpt_id)
    item.lob_id_label = that.$theia.enum.getName("my_business_line",item.lob_id)
    item.position_label = that.$theia.enum.getName("position",item.position)
    item.title_label = that.$theia.enum.getName("title",item.title)
    item.is_email_enabled_label = that.$theia.enum.getName("bool",item.is_email_enabled)
    item.status_label = that.$theia.enum.getName("status",item.status)
    item.staff_id_progress = item.staff_id
    item.name_progress = item.name
    item.dpt_id_progress = item.dpt_id
    item.lob_id_progress = item.lob_id
    item.position_progress = item.position
    item.title_progress = item.title
    item.mobile_progress = item.mobile
    item.email_progress = item.email
    item.is_email_enabled_switch = item.is_email_enabled == 0
    item.status_switch = item.status == 0
    item.create_time_progress = item.create_time
    item.le_staff_id = item.staff_id
    item.le_name = item.name
    item.le_dpt_id = item.dpt_id
    item.le_lob_id = item.lob_id
    item.le_position = item.position
    item.le_title = item.title
    item.le_mobile = item.mobile
    item.le_email = item.email
    item.le_is_email_enabled = item.is_email_enabled
    item.le_status = item.status
    item.le_create_time = that.$theia.str.dateFormat(item.create_time,'yyyy-MM-dd')
    item.create_time = that.$theia.str.dateFormat(item.create_time,'yyyy-MM-dd')
    if(item.children){
      that.resetItemData_aaayr(that,item.children)
    }
  });
  },
  onstatusSwitchChange(xfrom,v) {
      let form = {}
      form.status = v == true? 0 : 1;
      form.staff_id = xfrom.staff_id
      let that = this
      this.$theia.http.post("/ws/staff/info/switch",form).then(res=>{
        that.$notify.success({title: '成功',message: '修改状态成功',duration:5000})
      }).catch(res=>{
        v = !v
        let code = ((res||{}).response||{}).status||0
        let msg = `修改状态失败(${code})`
        that.$notify.error({title: '失败',message: msg,duration:5000})
      });
  },
    handleSelectionChange(lst=[]){
      this.bcheck = []
      lst.forEach(f=>{
        this.bcheck.push(f.staff_id)
      })
    },
    loadEnums_aaayr(){
        //部门
        this.dpt_idList = this.$theia.enum.get("department_info","","" ,false,"")
        //业务线
        this.lob_idList = this.$theia.enum.getTree("my_business_line","","" ,99)
        //岗位
        this.positionList = this.$theia.enum.get("position","","" ,false,"")
        //职位
        this.titleList = this.$theia.enum.get("title","","" ,false,"")
        //邮件通知
        this.is_email_enabledList = this.$theia.enum.get("bool","","" ,false,"")
        //状态
        this.statusTabList = this.$theia.enum.get("staff_status","","",false,"")
        //部门
        this.dpt_idList = this.$theia.enum.getTree("department_info","","" ,99)
        //业务线
        this.lob_idList = this.$theia.enum.get("my_business_line","","" ,false,"")
        //岗位
        this.positionList = this.$theia.enum.get("position","","" ,false,"")
        //职位
        this.titleList = this.$theia.enum.get("title","","" ,false,"")
        //状态
        this.statusList = this.$theia.enum.get("status","","" ,false,"")
    },

  handleSizeChange(ps){
    this.form_aaayr.ps = ps
    this.onQuery(true)
  },
  onlob_idChange(v){
    this.$theia.user.set("lob_id",v)
    this.loadEnums_aaayr()
    this.onQuery(true)
  },
  handleCurrentChange(pi){
    this.form_aaayr.pi = pi
    this.onQuery()
  },
  onQuery(refresh){
    if(refresh){
      this.form_aaayr.pi = 1
    }
    this.queryData_aaayr ()
  },
show_cmpnt(cmd,row){
  if(this.cmpnt_funcs[cmd]){
    this.cmpnt_funcs[cmd](row)
  }
},
  //详情
  show_cmpnt_aaayt(fm = {}){
    let query = {} 
    query.staff_id = fm.staff_id|| fm.le_staff_id 
    query.name = fm.name|| fm.le_name 
    query.dpt_id = fm.dpt_id|| fm.le_dpt_id 
    query.lob_id = fm.lob_id|| fm.le_lob_id 
    query.position = fm.position|| fm.le_position 
    query.title = fm.title|| fm.le_title 
    query.mobile = fm.mobile|| fm.le_mobile 
    query.email = fm.email|| fm.le_email 
    query.is_email_enabled = fm.is_email_enabled|| fm.le_is_email_enabled 
    query.status = fm.status|| fm.le_status 
    query.create_time = fm.create_time|| fm.le_create_time 
    query.staff_id = fm.staff_id

      //2023.4.18添加---

    query.$title="详情"
    this.$refs.cmpnt_aaayt.show(query)
  },
  //添加员工
  show_cmpnt_aaayv(fm = {}){
    let query = {} 
    query.name = fm.name|| fm.le_name 
    query.dpt_id = fm.dpt_id|| fm.le_dpt_id 
    query.lob_id = fm.lob_id|| fm.le_lob_id 
    query.position = fm.position|| fm.le_position 
    query.title = fm.title|| fm.le_title 
    query.mobile = fm.mobile|| fm.le_mobile 
    query.email = fm.email|| fm.le_email 
    query.is_email_enabled = fm.is_email_enabled|| fm.le_is_email_enabled 
    query.status = fm.status|| fm.le_status 
    query.staff_id = fm.staff_id

      //2023.4.18添加---
    query.is_email_enabled = "1"
    query.status = "0"

    query.$title="添加员工"
    this.$refs.cmpnt_aaayv.show(query)
  },
  //修改
  show_cmpnt_aaayu(fm = {}){
    let query = {} 
    query.name = fm.name|| fm.le_name 
    query.dpt_id = fm.dpt_id|| fm.le_dpt_id 
    query.lob_id = fm.lob_id|| fm.le_lob_id 
    query.position = fm.position|| fm.le_position 
    query.title = fm.title|| fm.le_title 
    query.mobile = fm.mobile|| fm.le_mobile 
    query.email = fm.email|| fm.le_email 
    query.is_email_enabled = fm.is_email_enabled|| fm.le_is_email_enabled 
    query.status = fm.status|| fm.le_status 
    query.staff_id = fm.staff_id

      //2023.4.18添加---

    query.$title="修改"
    this.$refs.cmpnt_aaayu.show(query)
  },
  //修改部门
  show_cmpnt_aaayw(fm = {}){
    let query = {}
    query.m = fm.w|| fm.le_w 
    query.staff_id = fm.staff_id

      //2023.4.18添加---
    query.staff_id = (this.bcheck||[]).join(",")

    query.$title="修改部门"
    this.$refs.cmpnt_aaayw.show_aaayw(query)
  },
},
};
</script>
<style>
.el-dialog{
  border-radius:5px !important
}
</style>
<style scoped>
.el-form-item {
  margin-right: 10px !important;
}

.opts .el-button--small {
  margin-left: 0px;
  padding-left: 0px;
  margin-right: 4px;
}

/deep/.el-table td.el-table__cell div {
  vertical-align: middle;
}
/deep/.el-button+.el-dropdown{
  margin-left:0px;
}
/deep/.el-button+.el-button{
  margin-left:0px;
}
.el-button{
  padding-left: 6px !important;
  padding-right: 6px !important;
}
.blist {
  margin-bottom: 8px;
  width: 100%;
}

.blist .el-radio-group {
  margin-right: 8px;
}

.ddl {
  margin-bottom: 8px;
  width: 100%;

}

.ddl .el-dropdown {
  margin-right: 8px;
}

.listbar {
  margin-bottom: 8px;
  text-align: center;
}
 .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
  font-size: 0.65rem;
}
/deep/.el-button--small{
  padding: 5px 4px;
}

.prepend /deep/.el-input__wrapper{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
}
.prepend+/deep/.el-date-editor{
  border-top-left-radius:0;
  border-bottom-left-radius:0;
  border-left:0;
}

</style>